package com.feather.common.converter.simple.fieldassignment;

import java.lang.reflect.Field;

import com.feather.common.converter.FieldAssignment;
import com.feather.common.util.ClassUtil;

/**
 * @author flogyin
 */
public class String_Long implements FieldAssignment {
	@Override
	public Object assign(Object value, Object obj, Field field) {
		Long l = null;
		String str = (String) value;
		if (str != null && str.length() > 0) {
			l = Long.valueOf(str);
		} else {
			if (long.class.getName().equals(field.getType().getName()))
				l = 0L;
		}

		ClassUtil.set(obj, field, l);
		return null;
	}
}
